from marshmallow import fields

from extensions import marshmallow as ma


class Query(ma.Schema):
    items = fields.List(fields.Dict)

    # pagination = fields.Nested(Pagination)

    def jsonify_with(self, items, pagination=None):
        return super().jsonify(
            {
                'items': items,
                'pagination': pagination
            }
        )


class GatewaySchema(ma.Schema):
    id = fields.Str()
    screen_name = fields.Str()
    type = fields.Str()


class TradeSchema(ma.Schema):
    id = fields.Str()
    amount = fields.Number()
    type = fields.Str()
    gateway_id = fields.Str()
    payment_time = fields.DateTime()
    fund_channel_id = fields.Str()
    remark = fields.Str()
    trade_code = fields.Str()


class FundChannelSchema(ma.Schema):
    id = fields.Str()
    status = fields.Str()
    description = fields.String()
    created_at = fields.DateTime()
    updated_at = fields.DateTime()
    name = fields.Str()
    # gateway = fields.Nested(GatewaySchema)


fund_channel_list = FundChannelSchema(many=True)

query_resp = Query()

trade = TradeSchema(many=False)
